• Description:
    Constants are in PowerD defined with one of following keyword: CONST, ENUM, SET and FLAG. Constants can be defined nearly everywhere you like inside or outside a procedure. PowerD recognizes currently only two types of constants. First and mostly used are normal LONGs, each constant can contain fully 32bit number (this will be in future expanded to 64 and 128 bits). Second constant type is DOUBLE. It contains 64bit IEEE floating point value. If You use such constants in incompatible way (like storing LONG constant in WORD or BYTE of memory) it will be converted to be compatible.
    If You define const with same name twice (or more times) compiler won't show any error messages. Always last defined constant will be used.
    Pay attention to local constants. Local ones will be used before the global ones.

  • CONST keyword definition:
      CONST name=value
    

    The value can be integer or float or their expressions.

    Examples:
      CONST COUNT=10,
            LISTSIZE=COUNT*SIZEOF_LONG,
            PI=3.1415926
    
  • ENUM keyword definition:
      ENUM name[=value]
    

    ENUM generates list of constants where each next constant is increased by one. Values must be LONGs.

    Examples:
      ENUM YES=-1,NO,MAYBE              // YES=-1,NO=0,MAYBE=1
      ENUM WHAT,IS,YOUR,NAME,           // WHAT=0,IS=1,YOUR=2,NAME=3
           MY=10,NAME,IS,PRINCE         // MY=10,NAME=11,IS=12,PRINCE=13
    
  • SET keyword definition:
      SET name[=value]
    

    where values are for 32bit numbers from 0 to 31. Each next constant has its bit shifted left by one. (respectively it is multiplied by two)

    Examples:
      SET VERTICAL,                     // VERTICAL=1
          SMOOTH,                       // SMOOTH=2
          DIRTY                         // DIRTY=4
      SET CLEAN=5,                      // CLEAN=32
          FAKE,                         // FAKE=64,
          SLOW=10                       // SLOW=1024
    
  • FLAG keyword definition:
      FLAG n_ame[=value]
    

    where n_ame is normal name, but it MUST contain "_" character (eg.: AG_Member, FI_Open). FLAG generates two constants from each the first is same as in SET case, but "F" is added before the first "_" character and the second is like ENUM, but "B" is added before the first "_" character. Values are the same as in SET case.

    Examples:
      FLAG CAR_Fast,                    // CARF_Fast=1,      CARB_Fast=0
           CAR_Auto,                    // CARF_Auto=2,      CARB_Auto=1
           CAR_Comfort,                 // CARF_Comfort=4,   CARB_Comfort=2
           CAR_Expensive                // CARF_Expensive=8, CARB_Expensive=3
    
  • Internal constants:
    All of following constants are automaticaly predefined before compilation.
      TRUE    = -1
      FALSE   = 0
      NIL     = 0                    // for pointers
      PI      = 3.141592653589
      OLDFILE = 1005                 // for file opening
      NEWFILE = 1006                 // for file opening
    
  • Special (changable) constants:
      OSVERSION = requied version of operation system (see: Options)
      STRLEN    = length of last used string
    
      PrintF('Hello\n')
      len:=STRLEN                    // len contains number 6
    
  • SIZEOF previxed constants:
    These constants gives length of each PowerD type. If You want to get length of an OBJECT, simply add before OBJECT's name prefix "SIZEOF_". List of predefined constants of length of types:
      SIZEOF_BYTE   = 1
      SIZEOF_UBYTE  = 1
      SIZEOF_WORD   = 2
      SIZEOF_UWORD  = 2
      SIZEOF_LONG   = 4
      SIZEOF_ULONG  = 4
      SIZEOF_FLOAT  = 4
      SIZEOF_DOUBLE = 8
      SIZEOF_PTR    = 4
      SIZEOF_BOOL   = 2
      SIZEOF_VOID   = 4
      SIZEOF_HALF   = 2              // this equals to WORD (for PPC machines)
      SIZEOF_UHALF  = 2              // this equals to UWORD (for PPC machines)
      SIZEOF_DLONG  = 8              // this is only for 64bit PPC machines
      SIZEOF_UDLONG = 8              // this is only for 64bit PPC machines